package com.suneast.suneaststore.modules.store;

import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.suneast.suneaststore.API;
import com.suneast.suneaststore.R;
import com.suneast.suneaststore.modules.common.GlideImageLoader;
import com.suneast.suneaststore.modules.goodsdetail.adapter.ProductAdapter;
import com.suneast.suneaststore.modules.homepage.adapter.CategoryAdapter;
import com.suneast.suneaststore.bean.homepage.ProductStoreCategoryItemBean;
import com.suneast.suneaststore.bean.homepage.RecommendProductBean;
import com.suneast.suneaststore.ui.banner.Banner;
import com.suneast.suneaststore.ui.banner.BannerConfig;
import com.suneast.suneaststore.ui.fragments.BaseFragment;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * Created by zestz on 2018/3/24.
 */

public class ExchangeStoreFragment extends BaseFragment {
    @Override
    public @LayoutRes
    int setLayout() {
        return R.layout.fragment_exchange_store;
    }


    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.banner_exchange_store)
    Banner exchangeStoreBanner;

    @BindView(R.id.rv_exchange_category)
    RecyclerView exchangeCategoryRV;

    @BindView(R.id.rv_red_wine)
    RecyclerView redWineRV;

    @BindView(R.id.rv_nutrition)
    RecyclerView nutritionRV; // 去库存

    @BindView(R.id.rv_bedding_goods)
    RecyclerView beddingGoodsRV;

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View rootView) {
        initView();
    }

    private void initView() {
        toolbar.setNavigationOnClickListener(v -> pop());
        ArrayList<String> bannerImgs = new ArrayList<>();
        bannerImgs.add(API.SITE + "/attachment/images/global/creditshop.jpg");
        exchangeStoreBanner.setImageLoader(new GlideImageLoader());
        exchangeStoreBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
        exchangeStoreBanner.isAutoPlay(true);
        exchangeStoreBanner.setImages(bannerImgs);
        exchangeStoreBanner.start();

        GridLayoutManager gridLayoutManager = new GridLayoutManager(
                getContext(), 4, GridLayoutManager.VERTICAL, false
        );
        exchangeCategoryRV.setLayoutManager(gridLayoutManager);
        ArrayList<ProductStoreCategoryItemBean> list = new ArrayList<>();
        list.add(new ProductStoreCategoryItemBean(
                110,
                "http://img2.suneastzy.com/a44C2e12sAz5RSZ2JAjjra264AAr21.jpg",
                "床上用品"));
        list.add(new ProductStoreCategoryItemBean(
                110,
                "http://img2.suneastzy.com/W95USomZuFSmUV77v77b9OFF7bi9Su.jpg",
                "清洁用品"));
        list.add(new ProductStoreCategoryItemBean(
                110,
                "http://img2.suneastzy.com/Ip9F49DZvMF9Gxz0X4DJCJFj6q9dL0.jpg",
                "手机配件"));
        list.add(new ProductStoreCategoryItemBean(
                110,
                "http://img2.suneastzy.com/woc3T0YlHTO9O73h9OzDQ93l0uL7o3.jpg",
                "红酒"));

        CategoryAdapter adapter =
                new CategoryAdapter(R.layout.item_product_store_category, list);
        exchangeCategoryRV.setAdapter(adapter);

        GridLayoutManager commonGrid = new GridLayoutManager(
                getContext(), 2, GridLayoutManager.VERTICAL, false
        );
        redWineRV.setLayoutManager(commonGrid);
        redWineRV.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
        redWineRV.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.HORIZONTAL));
        ProductAdapter goodsAdapter = new ProductAdapter(R.layout.item_star_product);
        ArrayList<RecommendProductBean> goodsList = new ArrayList<>();
        RecommendProductBean bean = new RecommendProductBean();
        bean.setId(1000);
        bean.setThumb("http://img2.suneastzy.com/X7j3piPcJ0QRp3iiEim6jNi6Eq0Rfc.jpg?imageView2/0/w/300/h/300/q/90|imageslim");
        bean.setTitle("蓝色波图精选白葡萄酒");
        bean.setDiscount(20.00);
        bean.setPrice("98.00");
        bean.setUnit("件");

        RecommendProductBean bean1 = new RecommendProductBean();
        bean1.setId(1000);
        bean1.setThumb("http://img2.suneastzy.com/USyQYS42SySkSs4BS22sZS2V41wVYy.jpg?imageView2/0/w/300/h/300/q/90|imageslim");
        bean1.setTitle("西班牙进口梦想家系列干红葡萄酒");
        bean1.setDiscount(25.00);
        bean1.setPrice("76.00");
        bean1.setUnit("件");

        RecommendProductBean bean2 = new RecommendProductBean();
        bean2.setId(1000);
        bean2.setThumb("http://img2.suneastzy.com/oHIpUB8z3Q8hMUChAUb0OHDwAPI0J0.jpg?imageView2/0/w/300/h/300/q/90|imageslim");
        bean2.setTitle("西班牙进口磨坊干红葡萄酒");
        bean2.setDiscount(26.00);
        bean2.setPrice("86.00");
        bean2.setUnit("件");

        RecommendProductBean bean3 = new RecommendProductBean();
        bean3.setId(1000);
        bean3.setThumb("http://img2.suneastzy.com/UaP2KJAL6a66M3pCbCjMbZL6b3yvBZ.jpg?imageView2/0/w/300/h/300/q/90|imageslim");
        bean3.setTitle("西班牙进口维拉诺干红葡萄酒");
        bean3.setDiscount(17.00);
        bean3.setPrice("89.00");
        bean3.setUnit("件");

        goodsList.add(bean);
        goodsList.add(bean1);
        goodsList.add(bean2);
        goodsList.add(bean3);
        goodsAdapter.addData(goodsList);
        redWineRV.setAdapter(goodsAdapter);

        GridLayoutManager commonGrid2 = new GridLayoutManager(
                getContext(), 2, GridLayoutManager.VERTICAL, false
        );
        nutritionRV.setLayoutManager(commonGrid2);
        nutritionRV.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
        nutritionRV.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.HORIZONTAL));
        ProductAdapter hotCakeAdapter = new ProductAdapter(R.layout.item_star_product);
        ArrayList<RecommendProductBean> hotCakeList = new ArrayList<>();
        RecommendProductBean bean20 = new RecommendProductBean();
        bean20.setId(1000);
        bean20.setThumb("http://img2.suneastzy.com/Rx6La4Cfd7D6T4LAJ3y6LK3u6LfX6i.jpg");
        bean20.setTitle("印度辣木子");
        bean20.setDiscount(35.00);
        bean20.setPrice("255.00");
        bean20.setUnit("件");
        RecommendProductBean bean21 = new RecommendProductBean();
        bean21.setId(1000);
        bean21.setThumb("http://img2.suneastzy.com/InA2VnKnkAcEz1N0pSqLzzNN1d3NpP.jpg");
        bean21.setTitle("贡菊");
        bean21.setDiscount(10.00);
        bean21.setPrice("70.00");
        bean21.setUnit("件");
        RecommendProductBean bean22 = new RecommendProductBean();
        bean22.setId(1000);
        bean22.setThumb("http://img2.suneastzy.com/cQ3drM1ntmMQmMMdxWW0oqb3qtrnB3.jpg");
        bean22.setTitle("心脑血管防护四通粉");
        bean22.setDiscount(162.00);
        bean22.setPrice("1188.00");
        bean22.setUnit("件");
        RecommendProductBean bean23 = new RecommendProductBean();
        bean23.setId(1000);
        bean23.setThumb("http://img2.suneastzy.com/DQbD8rKdprHr85EGO3dA3eRG1ZR1Do.jpg");
        bean23.setTitle("美国立头参");
        bean23.setDiscount(2.00);
        bean23.setPrice("15.00");
        bean23.setUnit("件");
        hotCakeList.add(bean20);
        hotCakeList.add(bean21);
        hotCakeList.add(bean22);
        hotCakeList.add(bean23);
        hotCakeAdapter.addData(hotCakeList);
        nutritionRV.setAdapter(hotCakeAdapter);

        GridLayoutManager commonGrid3 = new GridLayoutManager(
                getContext(), 2, GridLayoutManager.VERTICAL, false
        );
        beddingGoodsRV.setLayoutManager(commonGrid3);
        beddingGoodsRV.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
        beddingGoodsRV.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.HORIZONTAL));
        ProductAdapter destockinAdapter = new ProductAdapter(R.layout.item_star_product);
        ArrayList<RecommendProductBean> destockingList = new ArrayList<>();
        RecommendProductBean bean30 = new RecommendProductBean();
        bean30.setId(1000);
        bean30.setThumb("http://img2.suneastzy.com/bJ1fpqFbiW4P8G134G4BpB4V1wB7WI.jpg?imageView2/0/w/300/h/300/q/90|imageslim");
        bean30.setTitle("华龙绣品/纱花边系列");
        bean30.setDiscount(38.00);
        bean30.setPrice("21.00");
        bean30.setUnit("件");
        RecommendProductBean bean31 = new RecommendProductBean();
        bean31.setId(1000);
        bean31.setThumb("http://img2.suneastzy.com/S5fx8VpUVwdPww6VOVw5Wm2pDV24pd.jpg");
        bean31.setTitle("华龙绣品/方格系列");
        bean31.setDiscount(34.00);
        bean31.setPrice("18.00");
        bean31.setUnit("件");
        bean30.setId(1000);
        RecommendProductBean bean32 = new RecommendProductBean();
        bean32.setThumb("http://img2.suneastzy.com/Vvb0fcC80Fo1862nVz8m0emcbN99MM.jpg");
        bean32.setTitle("华龙绣品/长城花边系列");
        bean32.setDiscount(37.00);
        bean32.setPrice("20.00");
        bean32.setUnit("件");
        RecommendProductBean bean33 = new RecommendProductBean();
        bean33.setId(1000);
        bean33.setThumb("http://img2.suneastzy.com/T1aSQPSpfFAk1A7sK59Qpd795975Aq.jpg");
        bean33.setTitle("华龙绣品/正方形");
        bean33.setDiscount(31.00);
        bean33.setPrice("17.00");
        bean33.setUnit("件");
        destockingList.add(bean30);
        destockingList.add(bean31);
        destockingList.add(bean32);
        destockingList.add(bean33);
        destockinAdapter.addData(destockingList);
        beddingGoodsRV.setAdapter(destockinAdapter);
    }
}
